package com.itany.corejava.day06;

public class Test1 {

    public static void main(String[] args) {

        //栈里定义变量
        Person p;

        /*
            1.堆里分配空间
            2.自动初始化属性值
            3.调用构造方法
            4.将空间首地址赋值给变量p
         */
        p=new Person("abc",true);

        System.out.println("p = " + p);

        p.eat("肉");

        p.sleep();
        
        String name=p.getName();
        System.out.println("name = " + name);

//        System.out.println("p.name = " + p.name);
//        System.out.println("p.age = " + p.age);
//        System.out.println("p.sex = " + p.sex);
//        System.out.println("p.money = " + p.money);
//
//        p.money=555.0;
//        p.age=-56;

        p.setAge(-31);

        System.out.println(p.getAge());

        p.setAge(31);

        System.out.println(p.getAge());

        System.out.println(p.getSex());

        Person p2=new Person("aaa",false);

        System.out.println("p2 = " + p2);

        p2.eat("饭");

        p2.setSex("男");

        System.out.println(p2.getSex());

//        System.out.println("p2.name = " + p2.name);
//        System.out.println("p2.age = " + p2.age);
//        System.out.println("p2.sex = " + p2.sex);
//        System.out.println("p2.money = " + p2.money);
    }

}
